<?php
require_once("../config.php");
require_once("common_parameters.php");

$t = intval($_REQUEST['t']);
$paramInfo = $paramArray[$t];

if($t == 0){
	echo "<script>alert('栏目分类号码不正确!');</script>";
	echo "<script>location.href = './list.php?t=1';</script>";
	exit;
}

if(!empty($_POST['title'])){
	$title = addslashes($title);
	$row = $dsql->GetOne("select * From ".$paramInfo['tableName']." where val = '".$title."'");

	if($row['id'] <= 0){
		$sql = "insert into ".$paramInfo['tableName']."(id, val, status) values('', '".$title."', '1')";

		$dsql->ExecuteNoneQuery($sql);
		//$id = $dsql->GetLastID();
		echo "<script>alert('".$paramInfo['mainFieldTitle']."增加成功!');</script>";
		echo "<script>location.href = 'list.php?t=".$t."';</script>";
		exit;
	}else{
		echo "<script>alert('".$paramInfo['mainFieldTitle']."不能重复!');</script>";
		echo "<script>location.href = 'add.php?t=".$t."';</script>";
		exit;
	}
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><?=$paramInfo['addTitle']?></title>
<style type="text/css">
<!--
body { background-image: url(images/allbg.gif); }
.multipic {
	border: 1px dashed #FC6;
}
.albCt {
	border-bottom: 1px dashed #FC0;
	margin-bottom: 10px;
	padding-bottom:10px;
}
.albCt img{
	cursor:pointer;
}
-->
</style>
<link href="../css/base.css" rel="stylesheet" type="text/css">
<link href='../css/tb-box.css' rel='stylesheet' type='text/css' />
<script language="javascript">
<!--
function checkSubmit()
{
	if(document.form1.title.value=='')
	{
		alert('<?=$paramInfo['mainFieldTitle']?>标题不能为空!');
		return false;
	}
	return true;
}
-->
</script>
</head>
<body topmargin="8">
<form name="form1" action="add.php" method="post" onSubmit="return checkSubmit()">
  <table width="98%"  border="0" align="center" cellpadding="2" cellspacing="2" id="adset" style="border:1px solid #cfcfcf;background:#ffffff;">
  <tr bgcolor="#E7E7E7" >
	<td height="28" colspan="10" background="images/tbg.gif" style="padding-left:10px;">
	◆ <?=$paramInfo['addTitle']?>
	</td>
</tr>
  <tr>
   <td height="24" colspan="4" class="bline">
      <table width="800" border="0" cellspacing="0" cellpadding="0">
		  <tr>
			<td width="90">&nbsp;<?=$paramInfo['mainFieldTitle']?>:</td>
			<td width='408'>
				<input name="title" type="text" id="title" value="" style="width:388px" />
				<input name="t" type="hidden" value="<?=$t?>" />
			</td>
		  </tr>
		</table>
    </td>
  </tr>
  </table>
   <table width="98%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#F9FCEF" style="border:1px solid #cfcfcf;border-top:none;">
   <tr height="35">
    <td width="17%">&nbsp;</td>
    <td width="83%" align="right"><input name="imageField" type="submit" value="保存" width="60" height="22" class="np" border="0"  style="cursor:pointer;"/>
       <input type="button" value="重置" border="0" onClick="location.reload();" style="cursor:pointer; "/>
    <td width="20">&nbsp;</td>
    </td>
   </tr>
</table>
</form>
</body>
</html>